package com.tadpole.music.adapter.study;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.study.MyExamsFootBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.holder.base.NoDataEmpty;
import com.tadpole.music.holder.study.ExamsViewHolder;
import com.tadpole.music.holder.study.NowStudyViewHolder;

import java.util.List;

/**
 * 我的考试
 * Created By 孙岩
 * on 2020/9/28
 */
public class ExamsAdapter extends BaseAdapter {
    private Activity activity;
    private ExamsViewHolder examsViewHolder;
    private List<MyExamsFootBean.DataBeanX.DataBean> list;
    private OnItemClickListener onItemClickListener;
    public ExamsAdapter(Activity activity, List<MyExamsFootBean.DataBeanX.DataBean> list) {
        this.activity = activity;
        this.list = list;
    }

    @Override
    public BaseViewHolder createRelHolder(ViewGroup parent, int viewType) {
        if (list == null || list.size() == 0) {
            String empty = "NO_DATA";
            LayoutInflater layoutInflater = LayoutInflater.from(activity);
            View inflate = layoutInflater.inflate(R.layout.item_no_data, parent, false);
            NoDataEmpty noDataEmpty = new NoDataEmpty(inflate, empty);
            return noDataEmpty;
        } else {
            examsViewHolder = new ExamsViewHolder(LayoutInflater.from(activity).inflate(R.layout.item_exams, parent, false),list,onItemClickListener);
            return examsViewHolder;
        }
    }

    @Override
    public int getRelItemCount() {
        return list == null || list.size() == 0 ? 1 : list.size();
    }

    @Override
    public void setOnItemClickListener(OnItemClickListener listener) {
        this.onItemClickListener = listener;
    }

    @Override
    public void setOnChildClickListener(OnChildClickListener listener) {

    }

    @Override
    public void setOnLongClickListener(OnLongClickListener listener) {

    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
        holder.init(position - mHeadViews.size());
    }
}
